/**
 * @author nttdocomo
 */
define(function() {
	aries.klass('aries.CompositeElementLite', aries.Class.extend({

		initialize : function(elements, root) {
			/**
			 * @property {HTMLElement[]} elements
			 * The Array of DOM elements which this CompositeElement encapsulates.
			 *
			 * This will not *usually* be accessed in developers' code, but developers wishing to augment the capabilities
			 * of the CompositeElementLite class may use it when adding methods to the class.
			 *
			 * For example to add the `nextAll` method to the class to **add** all following siblings of selected elements,
			 * the code would be
			 *
			 *     Ext.override(Ext.dom.CompositeElementLite, {
			 *         nextAll: function() {
			 *             var elements = this.elements, i, l = elements.length, n, r = [], ri = -1;
			 *
			 *             // Loop through all elements in this Composite, accumulating
			 *             // an Array of all siblings.
			 *             for (i = 0; i < l; i++) {
			 *                 for (n = elements[i].nextSibling; n; n = n.nextSibling) {
			 *                     r[++ri] = n;
			 *                 }
			 *             }
			 *
			 *             // Add all found siblings to this Composite
			 *             return this.add(r);
			 *         }
			 *     });
			 *
			 * @readonly
			 */
			this.elements = [];
			this.add(elements, root);
			this.el = new Ext.dom.AbstractElement.Fly();
		}
	}, {
		/**
		 * @private
		 * Copies all of the functions from Ext.dom.Element's prototype onto CompositeElementLite's prototype.
		 * This is called twice - once immediately below, and once again after additional Ext.dom.Element
		 * are added in Ext JS
		 */
		importElementMethods : function() {
			var name, elementPrototype = Ext.dom.Element.prototype, prototype = this.prototype;

			for (name in elementPrototype) {
				if ( typeof elementPrototype[name] == 'function') {
					(function(key) {
						prototype[key] = prototype[key] ||
						function() {
							return this.invoke(key, arguments);
						};
					}).call(prototype, name);

				}
			}
		}
	}))
})
